package advanced;

import JaCoP.core.IntVar;
import JaCoP.core.Store;
import JaCoP.search.DepthFirstSearch;
import JaCoP.search.IndomainMin;
import JaCoP.search.Search;
import JaCoP.search.SelectChoicePoint;
import JaCoP.search.SimpleMatrixSelect;

public class TestLex {
	private static Store store = new Store();

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		long T1, T2, T;
		T1 = System.currentTimeMillis();
		scheduleWorkers();
		T2 = System.currentTimeMillis();
		T = T2 - T1;
		System.out.println("\n\t*** Execution time = " + T + " ms");
	}

	private static void scheduleWorkers() {
		IntVar[] d = new IntVar[6]; 
	      for (int i = 0; i < d.length; i++) { 
	          d[i] = new IntVar(store, "d["+i+"]", 0, 2); 
	      } 
	 
	      IntVar[][] x = { {d[0],d[1]}, {d[2]}, {d[3],d[4]}, {d[5]} }; 
	 
	     // store.imposeDecomposition(new Lex(x, true));

		Search<IntVar> label = new DepthFirstSearch<IntVar>();

		SelectChoicePoint<IntVar> select = new SimpleMatrixSelect<IntVar>(
				x, new IndomainMin<IntVar>());
		//label.setSolutionListener(new PrintOutListener<IntVar>());
		label.getSolutionListener().searchAll(true);
		label.getSolutionListener().recordSolutions(true);

		boolean Result = label.labeling(store, select);

		if (Result) {
			label.printAllSolutions();
			
		} else {
			System.out.println("\n*** No");
		}

	}

}
